<?php
require_once '../DTO/danhmuc.php';
require_once 'DBConnection.php';

class danhmucDAO extends DBConnection{
	public function __construct(){
		parent::__construct();
	}
	
	public function getAllDanhMuc(){		
		$sql = "select * from danhmuc";
		
		$res = mysql_query($sql, $this->hDB);
		
		if(!$res){
			die("failed getting danh muc");
		}
		
		if(mysql_num_rows($res)){
			$obj = array();
			$temp = mysql_fetch_assoc($res);
			while ($temp){
				$obj[] = new danhmuc($temp['madanhmuc'], $temp['tendanhmuc'], $temp['mota']);
				$temp = mysql_fetch_assoc($res);
			}
			return $obj;
		}else{
			return null;
		}
	}
}